using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using Services;
using UniversityManagerWebSite.Models.Validation;
using IServices;
using GestionLinqLibData;


namespace UniversityManagerWebSite.Controllers
{
    public class TypeExamController : Controller
    {
        private ITypeExamService _service;

        public TypeExamController()
        {
            _service = new TypeExamService(new ModelStateWrapper(this.ModelState));

        }

        public TypeExamController(ITypeExamService service)
        {
            _service = service;

        }
        //
        // GET: /TypeExam/

        public ActionResult Index()
        {
            return View(_service.ListTypes());
        }

        //
        // GET: /TypeExam/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /TypeExam/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /TypeExam/Create

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create([Bind(Exclude = "id_exam")]type_exam typeToCreate)
        {
            if (_service.CreateType(typeToCreate))
                return RedirectToAction("Index");

            return View();

        }

        //
        // GET: /TypeExam/Edit/5

        public ActionResult Edit(int id)
        {
            return View(_service.GetType(id));
        }

        //
        // POST: /TypeExam/Edit/5

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Edit(type_exam typeToEdit)
        {
            if (_service.EditType(typeToEdit))
                return RedirectToAction("Index");
            return View(typeToEdit);

        }

        public ActionResult Delete(int id)
        {
            return View(_service.GetType(id));
        }

        //
        // POST: /TypeExam/Edit/5

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Delete(type_exam typeToDelete)
        {
            if (_service.DeleteType(typeToDelete))
                return RedirectToAction("Index");
            return View(typeToDelete);

        }
    }
}
